'''
Description: description
Author: 
LastEditors: M
'''
import json
import os
import time
def _ok_(s):
    return f"\033[1;33m{s}\033[0m"
def _primary_(s):
    return f"\033[1;34m{s}\033[0m"
def _emphasis_(s):
    return f"\033[1;31m{s}\033[0m"
def _warning_(s):
    return f"\033[1;33m{s}\033[0m"
def errormsg(*k,emphasis=None):
    msg = ",".join(k)
    print(f"ERROR:{msg}",end="")
    if emphasis:
        print(f"\033[1;31m\n\t{emphasis}\033[0m")
    else:
        print("")

def load_json(fp:str):
    if not os.path.exists(fp):
        errormsg("文件不存:",emphasis=fp)
        exit(-1)
    try:
        c = json.load(open(fp,encoding='utf-8'))
        return c
    except Exception as e:
        errormsg("json文件加载错误,检查内容格式是否正确",emphasis=f"{fp}\n\t{str(e)}")
        exit(-1)
def try_makedirs(p):
    if not os.path.exists(p):
        os.makedirs(p)
        
def print_with_time(*k):
    print(time.asctime(),*k)